package com.atguigu.binaryTree;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class InOrderInStack {
    public static List<Integer> inOrderUnRecur(TreeNode root){
        if(root==null) return new ArrayList<>();
        Stack<TreeNode> stack=new Stack<>();
        List<Integer> list=new ArrayList<>();
        while(!stack.isEmpty()){
            if(root!=null){
                stack.push(root);
                if(root.left!=null){
                    root=root.left;
                }
            }else{
                list.add(stack.pop().val);
                root=root.right;
            }
        }
        return list;
    }
}
